Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added reactive SortedSet #630

Merged
merged 11 commits into from
Jan 25, 2024
Merged

Feat: Added reactive SortedSet #630

merged 11 commits into from
Jan 25, 2024

Conversation

hmoog
Copy link
Contributor

@hmoog hmoog commented Jan 11, 2024

Description of change

This PR introduces a reactive SortedSet, which extends the capabilities of the Set to derive a perception of weight and order for its elements.

We expose the information through the following additional API endpoints:

// SortedSet is a reactive Set implementation that allows consumers to subscribe to its changes 
// and that keeps a sorted perception of its elements.
type SortedSet[ElementType comparable] interface {
	// Set imports the methods of the Set interface.
	Set[ElementType]

	// Ascending returns a slice of all elements of the set in ascending order.
	Ascending() []ElementType

	// Descending returns a slice of all elements of the set in descending order.
	Descending() []ElementType

	// HeaviestElement returns the element with the heaviest weight.
	HeaviestElement() ReadableVariable[ElementType]

	// LightestElement returns the element with the lightest weight.
	LightestElement() ReadableVariable[ElementType]
}

Type of change

  • Enhancement (a non-breaking change which adds functionality)

Change checklist

  • My code follows the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

ds/reactive/sorted_set_test.go Show resolved Hide resolved
ds/reactive/sorted_set_impl.go Outdated Show resolved Hide resolved
ds/reactive/sorted_set_impl.go Show resolved Hide resolved
@piotrm50 piotrm50 merged commit ebf40dc into develop Jan 25, 2024
52 checks passed
@piotrm50 piotrm50 deleted the feat/sorted-set branch January 25, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants